"""
database为数据库层，用于写对数据库增删改查等操作
主要使用mysql_cli，并且用git+https://tcsthyc@bitbucket.org/tcsthyc/mysql-cli-py.git@main封装好的四种函数
"""

from datetime import datetime
from mysql_cli import Select, Insert, Update, SelectMany

# 筛选
@Select("select config_value from yfb_config where config_key = 'login_type';")
def get_login_type():
    return

# 新建
@Insert("insert into yfb_team (team_name, team_num, state, remark, is_deleted, created_at, update_at, expire_at) "
        "values (?, ?, ?, ?, ?, ?, ?, ?);")
def new_team(user_params):
    return user_params.get('team_name'), 0, 1, user_params.get('remark'), 0, datetime.now(), datetime.now(), user_params.get('expire_at')

# 更新
@Update("update yfb_team set state = 0, update_at = ? where user_name = ?;")
def stop_user(user_name):
    return datetime.now(), user_name

# 筛选多个
@SelectMany("select user_name from yfb_user where role_id = ? and is_deleted = 0;")
def select_user_role_id(role_id):
    return role_id